package com.waiting.reflection;

import java.lang.reflect.Field;

/**
 * @desctiption
 * @Author bjweitingting
 * @date 2018/4/27
 **/
public class Main {
    public static void main(String[] args) {
        try {
            //第一种，通过forName获取class
            Class c1 = Class.forName("com.waiting.reflection.ReflectionClass2");
            System.out.println(c1.getName());

            //第二种，通过类的静态属性
            Class c2 = ReflectionClass.class;
            System.out.println(c2.getName());

            System.out.println("c1==c2:" + (c1 == c2));


            //第三种，通过对象的getClass()方法
            ReflectionClass obj = new ReflectionClass();

            Class c3 = obj.getClass();
            System.out.println(c3.getName());

            //获取到class，就可以对类的静态实例进行操作
            Field test = c1.getField("value");
            System.out.println(test.get(obj));

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public static  void test(){
        Integer test=new Integer(100);

    }
}
